package edu.mit.media.fv.components
{
	import flash.display.*;
	import flash.events.FocusEvent;
	import flash.text.*;
	
	public class FVTab extends Sprite
	{
		
		private var _width:int;
		private var _height:int;
		private var _color:uint;
		private var _selectedColor:uint;
		private var _text:String;
		
		private var _label:TextField;
		private var _format:TextFormat;
		
		public function FVTab(width:int, height:int, color:uint, text:String){
			super();
			this._width = width;
			this._height = height;
			this._color = 0x000000;
			this._selectedColor = color;
			this._text = text;
			
			_format = new TextFormat();
			_format.align = TextFormatAlign.CENTER;
			_format.bold = true;
			_format.font = "Arial";
			_format.size = 20;
			_format.color = 0xFFFFFF;
			_format.italic = true;
			this._label = new TextField();
			this._label.defaultTextFormat = this._format;
			
			this._label.type = TextFieldType.DYNAMIC;
			this._label.selectable = false;
			this._label.text = text;
			this._label.width = width;
			this._label.height = height;
			this.addChild(this._label);
			
			this.reform();
		}
		
		private var _selected:Boolean = false;
		public function get selected():Boolean {return this._selected;}
		public function set selected(selected:Boolean):void{
			this._selected = selected;
			this.reform();
		}
		
		private function reform():void{
			this.graphics.clear();
			if(this.selected){
				this.graphics.beginFill(this._selectedColor, 1.0);
				this.graphics.lineStyle(1, this._selectedColor , 1.0, true);
			}else{
				this.graphics.beginFill(this._color, 1.0);
				this.graphics.lineStyle(1, this._selectedColor , 1.0, true);
			}			
			//this.userTab.graphics.drawRoundRect(0,0,this._width,this._height+15,15,15);
			this.graphics.moveTo(0, this._height);
			this.graphics.lineTo(0,0+15);
			this.graphics.curveTo(0,0,15,0);
			this.graphics.lineTo(this._width-15, 0);
			this.graphics.curveTo(this._width, 0, this._width, 15);
			this.graphics.lineTo(this._width, this._height);
			this.graphics.lineTo(0, this._height);
			this.graphics.endFill();
			
		}
	}
}